<%-- 
    Document   : deleteEvent
    Created on : 19-gen-2015, 09.11.01
    Author     : Jov
--%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="refresh" content="3; url=../index.jsp">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>I-I-I'm here to delete a calendar, p-p-please be gentle, s-senpai-san!</h1>
        <%
            try {
                String connectionURL = "jdbc:mysql://localhost:3306/meteocaldb";
                Connection connection = null;
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                connection = DriverManager.getConnection(connectionURL, "root", "0000");
               
                Statement stmt = connection.createStatement();
               
                stmt.executeUpdate("DELETE FROM events WHERE calendar_id = " + request.getParameter("calendar_id") + "");
                stmt.executeUpdate("DELETE FROM calendars WHERE calendar_id = " + request.getParameter("calendar_id") + "");
               
                stmt.close();
                connection.close();
               
            } catch (Exception ex) {
                out.println("Errore! " + ex.getMessage().toString());
            }
        %> 
    </body>
</html>
